package com.cs.study.homework._0304;

import java.io.*;

public class Demo3 {
    public static void main(String[] args) throws IOException {
        encodeFile(new File("E:\\encodeFile\\encodingFile.txt"));

    }

    public static void encodeFile(File encodingFile) throws IOException {
        FileInputStream in = new FileInputStream("E:\\encodeFile\\encodingFile.txt");
        int readCount = in.read();
        byte[] bytes = new byte[readCount];
        int readData = in.read(bytes);
        for (int i = 0; i < readCount; i++) {
            while (bytes[i] >= '0' && bytes[i] <= '8') {
                bytes[i] += 1;
                if (bytes[i] == 9) {
                    bytes[i] = 0;
                }
            }
            while (bytes[i] >= 'a' && bytes[i] <= 'y') {
                bytes[i] += 1;
                if (bytes[i] == 'z') {
                    bytes[i] = 'a';
                }
            }
            while (bytes[i] >= 'A' && bytes[i] <= 'Y') {
                bytes[i] += 1;
                if (bytes[i] == 'Z') {
                    bytes[i] = 'A';
                }
            }
        }
    }
}
